<template>
  <!-- 入库管理 -->
  <el-container>
    <el-header>
      <div class="left-panel">
        <!-- <el-button type="primary" icon="el-icon-plus" @click="add"></el-button> -->
      </div>
      <div class="right-panel">
        <div class="right-panel-search">
          <!-- <el-input
            v-model="searchValue.search"
            placeholder="仓库名称"
            clearable
          ></el-input>
          <el-button
            type="primary"
            icon="el-icon-search"
            @click="upsearch"
          ></el-button> -->
          <!-- <el-select
            v-model="searchValue.type"
            placeholder="请选择类型"
            clearable
            @change="upsearch"
            style="width: 100%"
          >
            <el-option
              v-for="item in typeList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select> -->
        </div>
      </div>
    </el-header>
    <el-main class="nopadding">
      <scTable
        ref="table"
        :apiObj="apiObj"
        :params="params"
        row-key="id"
        stripe
        @row-dblclick="handleRowDblclick"
      >
        <el-table-column label="ID" prop="id" width="50"></el-table-column>
        <el-table-column
          label="单号"
          prop="inoutCode"
          width="250"
        ></el-table-column>
        <el-table-column
          label="仓库名称"
          prop="warehouseName"
          min-width="100"
        ></el-table-column>
        <!-- <el-table-column label="类型" prop="warehouseName" width="250">
           1领用 2盘点 3调拨  
          <template #default="scope">
            <p v-if="scope.row.type == 1">领用</p>
            <p v-if="scope.row.type == 2">盘点</p>
            <p v-if="scope.row.type == 3">调拨</p>
          </template>
        </el-table-column> -->
        <el-table-column
          label="部门"
          prop="departmentName"
          width="250"
        ></el-table-column>
        <el-table-column
          label="领用人/盘点人"
          prop="userName"
          width="250"
        ></el-table-column>
        <el-table-column
          label="经办人"
          prop="operatorName"
          width="200"
        ></el-table-column>
        <el-table-column
          label="出库时间"
          prop="inoutTime"
          width="200"
        ></el-table-column>
        <el-table-column label="操作" fixed="right" align="center" width="250">
          <template #default="scope">
            <!-- 是否确认：0否 1是 -->
            <el-button-group>
              <el-button
                text
                type="primary"
                size="small"
                @click="table_confirm(scope.row, scope.$index)"
                v-if="
                  scope.row.isPassed == 0 &&
                  userInfo.userId == scope.row.responsibleId
                "
                >确认入库</el-button
              >
              <el-button
                text
                type="primary"
                size="small"
                @click="table_show(scope.row, scope.$index)"
                >查看</el-button
              >
            </el-button-group>
          </template>
        </el-table-column>
      </scTable>
    </el-main>
  </el-container>
</template>

<script>

export default {
  name: 'warehouseIn',
  data () {
    return {
      dialog: {
        confirm: false,
      },
      apiObj: this.$API.inventory.getInoutList,
      userInfo: null,
      params: { inoutType: 2 },//inoutType出入库类型：1出库 2入库 
      searchValue: {
        type: null
      },
      typeList: [{ label: '领用', value: 1 }, { label: '盘点', value: 2 }, { label: '调拨', value: 3 }]
    }
  },
  created () {
    this.userInfo = this.$TOOL.data.get('USER_INFO')
  },
  methods: {
    //确定入库单
    table_confirm (row) {
      this.$router.push({
        path: '/goods/warehouseIn/warehouseInDetail',
        query: {
          id: row.id,
          mode: 'edit'
        }
      })

    },

    //查看
    table_show (row) {
      this.$router.push({
        path: '/goods/warehouseIn/warehouseInDetail',
        query: {
          id: row.id
        }
      })
    },

    //搜索
    upsearch () {
      this.$refs.table.upData(this.searchValue)
    },

    //本地更新数据
    handleSaveSuccess (data, mode) {
      if (mode == 'add') {
        // this.$refs.table.refresh()
      } else if (mode == 'edit') {
        // this.$refs.table.refresh()
      }
      this.$refs.table.refresh()
    },

    // 双击表格
    handleRowDblclick (row) {
      this.table_show(row)
    }

  }

}
</script>

<style>
</style>